/**
de
 * 通用API接口
 */
import api from '@/api/request'

let domain = ''

// 获取极速验证信息
export const getGtInfo = function (success, error) {
  api.get(`${domain}api/v2/user/gtCaptcha`, {cancel:false}).then(res=>{
    if(res.rst == api.SUCCESS) {
      success && success(res.data)
    } else {
      error && error(res.msg)
    }
  })
}


// 获取线上国际化
export const getLang = function (lang) {
  let _lang = lang
  switch(lang){
    case 'zh-TW':
      _lang = 'cht'
      break
    case 'en-US':
      _lang = 'en'
      break
    default:
      break
  }
  return api.get(`${domain}api/v2/language/${_lang}?_t=${new Date().getTime()}`, {cache:true, cancel:false})
  .then(result=>{
      if (result.rst == api.SUCCESS && result.data) {
            return  Promise.resolve(result.data)
      } else {
            return Promise.resolve()
      }
  })
  .catch(msg=>{
      return Promise.resolve()
  })
}

// 获取国家区域信息
export const getCountrys = function (success, error) {
  return api.get(`${domain}api/v2/individual/country`, {
    cache: 60*60*24
  })
}